﻿@using Smartstore.Web.Models.Catalog;

@model ProductsByTagModel

@{
    Assets.AppendTitleParts(T("PageTitle.ProductsByTag", Model.TagName));
    Assets.AppendMetaDescriptionParts(T("PageTitle.ProductsByTag", Model.TagName));

    if (Model.CanonicalUrl.HasValue())
    {
        Assets.AppendCanonicalUrlParts(Model.CanonicalUrl);
    }

    ViewBag.HideLeftCol = true; // ...on mobile
}

@if (Model.SearchResult.Facets.Count > 0)
{
    <widget target-zone="left">
        <partial name="Search.Filters" model="Model.SearchResult" />
    </widget>
}

<div class="page product-tag-page">
    <div class="page-title">
        @{
            var langAttrs = string.Empty;
            if (Model.TagName.HasValue() && Model.TagName.BidiOverride && Model.TagName.CurrentLanguage.Rtl)
            {
                langAttrs = $" lang=\"{Model.TagName.CurrentLanguage.GetTwoLetterISOLanguageName()}\" dir=\"rtl\"";
            }
        }
        <h1 class="h3 d-flex align-items-baseline">@Html.Raw(T("Products.Tags.ProductsTaggedWith", $"<small{langAttrs} class='search-term pl-2'>{Model.TagName}</small>"))</h1>

        @if (Model.SearchResult.TotalHitsCount > 0)
        {
            <partial name="SearchResultHitsCount" model="Model.SearchResult" />
        }
    </div>

    <div class="page-body">
        <zone name="productsbytag_top" />

        <div class="product-list-container">
            @if (Model.Products != null)
            {
                <partial name="Product.List" model="Model.Products" />
            }
        </div>

        @* TODO: (mc) find more intelligent way of rendering RecentlyViewedProducts globally *@
        @await Component.InvokeAsync("RecentlyViewedProducts")
        <zone name="productsbytag_bottom" />
    </div>
</div>
